home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / structinsert.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  2.1 KB  |  68 lines

  1. <!--- This example shows how to use the StructInsert
  2.       function. It calls the CF_ADDEMPLOYEE custom tag,
  3.       which uses the addemployee.cfm file. --->
  4. <html>
  5. <head>
  6. <title>StructInsert Function</title>
  7. </head>
  8.  
  9. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  10. <BODY  bgcolor="#FFFFD5">
  11.  
  12. <h3>StructInsert Example</h3>
  13. <h3>Add New Employees</h3>
  14. <P>
  15. This example uses the StructInsert function. To run this snippet
  16. under UNIX, you must add employee ID generation logic 
  17. to the addemployee.cfm file.
  18. <!--- Establish parms for first time through  --->
  19. <CFPARAM name="FORM.firstname" default="">
  20. <CFPARAM name="FORM.lastname" default="">
  21. <CFPARAM name="FORM.email" default="">
  22. <CFPARAM name="FORM.phone" default="">
  23. <CFPARAM name="FORM.department" default=""> 
  24.  
  25. <CFIF #FORM.firstname# EQ "">
  26.  <P>Please fill out the form.
  27. <CFELSE>
  28.   <CFOUTPUT>
  29.    <CFSCRIPT>
  30.      employee=StructNew();
  31.      StructInsert(employee, "firstname", FORM.firstname);
  32.      StructInsert(employee, "lastname", FORM.lastname);
  33.      StructInsert(employee, "email", FORM.email);
  34.      StructInsert(employee, "phone", FORM.phone);
  35.      StructInsert(employee, "department", FORM.department);
  36.   </CFSCRIPT> 
  37.  
  38.   <P>First name is #StructFind(employee, "firstname")#</p>
  39.   <P>Last name is #StructFind(employee, "lastname")#</p>
  40.   <P>EMail is #StructFind(employee, "email")#</p>
  41.   <P>Phone is #StructFind(employee, "phone")#</p>
  42.   <P>Department is #StructFind(employee, "department")#</p>
  43.   </cfoutput>
  44.  
  45.   <!--- Call the custom tag that adds employees --->
  46.   <CF_ADDEMPLOYEE EMPINFO="#employee#">
  47. </cfif>
  48.  
  49. <hr>
  50. <FORM action="structinsert.cfm" method="post">
  51. <P>First Name: 
  52. <INPUT name="firstname" type="text" hspace="30" maxlength="30">
  53. <P>Last Name: 
  54. <INPUT name="lastname" type="text" hspace="30" maxlength="30">
  55. <P>EMail: 
  56. <INPUT name="email" type="text" hspace="30" maxlength="30">
  57. <P>Phone: 
  58. <INPUT name="phone" type="text" hspace="20" maxlength="20">
  59. <P>Department: 
  60. <INPUT name="department" type="text" hspace="30" maxlength="30">
  61.  
  62. <P>
  63. <input type="submit" value="OK">
  64. </FORM>
  65.  
  66. </body>
  67. </html>
  68.